package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-10-31 18:11
 **/
public class LeetCode53 {

    public int maxSubArray(int[] nums) {
        int f = nums[0];
        int max = nums[0];
        for (int i = 1; i < nums.length; i++) {
            f = Math.max(f + nums[i], nums[i]);
            max = Math.max(f, max);
        }
        return max;
    }

}
